<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="favicon.ico"><![endif]--><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/roboto@4.5.0/400.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@5.9.55/css/materialdesignicons.min.css"><title>文件管理 - File Explorer</title><style>::-webkit-scrollbar-track {
      box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
      background-color: #F5F5F5;
    }

    ::-webkit-scrollbar {
      width: 10px;
      background-color: #F5F5F5;
    }

    ::-webkit-scrollbar-thumb {
      background-color: #1b76d2;
      background-image: -webkit-gradient(linear, 0 0, 0 100%,
          color-stop(.5, rgba(255, 255, 255, .2)),
          color-stop(.5, transparent), to(transparent));
    }</style><script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.min.js"></script><script src="https://cdn.bootcdn.net/ajax/libs/vuex/3.6.2/vuex.min.js"></script><script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.5.2/vue-router.min.js"></script><link href="https://cdn.jsdelivr.net/npm/vuetify@2.5.6/dist/vuetify.min.css" rel="stylesheet"><script src="https://cdn.jsdelivr.net/npm/vuetify@2.5.6/dist/vuetify.min.js"></script><script src="https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-min-noconflict/ace.js"></script><script>ace.config.set('basePath', 'https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-min-noconflict/');
    window.onbeforeunload = function () { return "确定离开当前页吗？"; }</script><link href="css/chunk-364725e8.bc1b9fdf.css" rel="prefetch"><link href="css/chunk-5a457659.4d7ad6ce.css" rel="prefetch"><link href="js/chunk-0b8e1363.aaa5ffac.js" rel="prefetch"><link href="js/chunk-2d0b2007.ae740451.js" rel="prefetch"><link href="js/chunk-2d0b2536.aa1846ee.js" rel="prefetch"><link href="js/chunk-2d0c17b9.50e51c13.js" rel="prefetch"><link href="js/chunk-2d0ccbf6.fd580af7.js" rel="prefetch"><link href="js/chunk-2d0daf50.627b9153.js" rel="prefetch"><link href="js/chunk-2d0e88ff.da75929b.js" rel="prefetch"><link href="js/chunk-2d20f8d9.c787b268.js" rel="prefetch"><link href="js/chunk-2d2105d2.5b61e6f6.js" rel="prefetch"><link href="js/chunk-2d213ebd.b1a95147.js" rel="prefetch"><link href="js/chunk-2d2248b2.0091e110.js" rel="prefetch"><link href="js/chunk-2d2293db.c1def1e4.js" rel="prefetch"><link href="js/chunk-2d229989.425db9be.js" rel="prefetch"><link href="js/chunk-2d35d068.897c42c4.js" rel="prefetch"><link href="js/chunk-364725e8.f5368c21.js" rel="prefetch"><link href="js/chunk-3c2917bf.e1270303.js" rel="prefetch"><link href="js/chunk-5a457659.fded490c.js" rel="prefetch"><link href="js/chunk-6021c06a.ea0d6d3d.js" rel="prefetch"><link href="js/app.cd5a52f8.js" rel="preload" as="script"><link href="js/chunk-vendors.f147ec59.js" rel="preload" as="script"><link rel="icon" type="image/png" sizes="32x32" href="img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="img/icons/favicon-16x16.png"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="ha_file_explorer"><link rel="apple-touch-icon" href="img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but 文件管理 - File Explorer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>class HA {
      constructor() {
        // url参数
        let query = new URLSearchParams(location.search)
        this.query = (key) => {
          let val = query.get(key)
          if (val) {
            return decodeURIComponent(val)
          }
          return val
        }
        this.ver = this.query('ver')
      }

      get hass() {
        const homeassistant = top.document.querySelector('home-assistant')
        return homeassistant ? homeassistant.hass : null
      }

      fullscreen() {
        try {
          let haPanelIframe = top.document.body
            .querySelector("home-assistant")
            .shadowRoot.querySelector("home-assistant-main")
            .shadowRoot.querySelector("app-drawer-layout partial-panel-resolver ha-panel-iframe").shadowRoot
          let ha_card = haPanelIframe.querySelector("iframe");
          ha_card.style.position = 'absolute'
          haPanelIframe.querySelector('app-toolbar').style.display = 'none'
          ha_card.style.top = '0'
          ha_card.style.height = '100%'
        } catch {

        }
      }

      // 触发事件
      fire(type, data, ele = null) {
        console.log(type, data)
        const event = new top.Event(type, {
          bubbles: true,
          cancelable: false,
          composed: true
        });
        event.detail = data;
        if (!ele) {
          ele = top.document.querySelector("home-assistant")
            .shadowRoot.querySelector("home-assistant-main")
            .shadowRoot.querySelector("app-drawer-layout")
        }
        ele.dispatchEvent(event);
      }

      post(params) {
        return this.fetch('/ha_file_explorer-api', params, 'post')
      }

      put(params) {
        return this.fetch('/ha_file_explorer-api', params, 'put')
      }

      callService(name, params = {}) {
        const arr = name.split('.')
        return this.hass.callService(arr[0], arr[1], params)
      }

      // http请求
      async fetch(url, params, method) {
        const body = toString.call(params) == '[object FormData]' ? params : JSON.stringify(params)
        const { hass } = this
        if (!hass) {
          return fetch(top.location.origin + url, {
            method,
            body,
            headers: {
              authorization: 'Bearer ' + hass.auth.data.access_token
            }
          }).then(res => res.json())
        }
        return hass.fetchWithAuth(url, {
          method,
          body
        }).then(async res => {
          const contentType = res.headers.get('Content-Type')
          if (contentType === 'application/octet-stream') {
            const blob = await res.blob()
            let bl = new Blob([blob], { type: blob.type });
            var link = top.document.createElement('a');
            link.href = top.URL.createObjectURL(blob);
            link.download = params.path.substr(params.path.lastIndexOf('/') + 1)
            link.click();
            top.URL.revokeObjectURL(link.href)
            return { msg: '下载成功' }
          }
          return res.json()
        })
      }
    }

    window.ha = new HA();
    window.ha.fullscreen()</script><script src="js/chunk-vendors.f147ec59.js"></script><script src="js/app.cd5a52f8.js"></script></body></html>